home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-05 / drivers1.zip / 3C523.ASM < prev    next >
Assembly Source File  |  1992-01-23  |  7KB  |  306 lines

  1. version    equ    1
  2.  
  3.     include    defs.asm
  4.  
  5. ;Ported from Tim Krauskopf's micnet.asm, an assembly language
  6. ;driver for the MICOM-Interlan NI5210 by Russell Nelson.  Any bugs
  7. ;are due to Russell Nelson.
  8. ;3c523 version Dan Lanciani ddl@harvard.* (received 5-18-89)
  9. ;Added Brad Clements' 1500 byte MTU, Russell Nelson.
  10.  
  11. ;  Copyright, 1988-1992, Russell Nelson, Crynwr Software
  12.  
  13. ;   This program is free software; you can redistribute it and/or modify
  14. ;   it under the terms of the GNU General Public License as published by
  15. ;   the Free Software Foundation, version 1.
  16. ;
  17. ;   This program is distributed in the hope that it will be useful,
  18. ;   but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. ;   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. ;   GNU General Public License for more details.
  21. ;
  22. ;   You should have received a copy of the GNU General Public License
  23. ;   along with this program; if not, write to the Free Software
  24. ;   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  25.  
  26. code    segment    word public
  27.     assume    cs:code, ds:code
  28.  
  29. ;
  30. ;  Equates for controlling the 3c523 board
  31. ;
  32. IOC    EQU    6
  33.  
  34.     public    int_no
  35. int_no        db    3,0,0,0        ; interrupt number
  36. io_addr        dw    300h,0        ; I/O address for card
  37. base_addr    dw      0c000h,0    ; base segment for board
  38.  
  39.     public    driver_class, driver_type, driver_name, driver_function, parameter_list
  40. driver_class    db    BLUEBOOK, IEEE8023, 0        ;from the packet spec
  41. driver_type    db    13        ;from the packet spec
  42. driver_name    db    "3C523",0    ;name of the driver.
  43. driver_function    db    2
  44. parameter_list    label    byte
  45.     db    1    ;major rev of packet driver
  46.     db    9    ;minor rev of packet driver
  47.     db    14    ;length of parameter list
  48.     db    EADDR_LEN    ;length of MAC-layer address
  49.     dw    GIANT    ;MTU, including MAC headers
  50.     dw    MAX_MULTICAST * EADDR_LEN    ;buffer size of multicast addrs
  51.     dw    0    ;(# of back-to-back MTU rcvs) - 1
  52.     dw    0    ;(# of successive xmits) - 1
  53. int_num    dw    0    ;Interrupt # to hook for post-EOI
  54.             ;processing, 0 == none,
  55.  
  56. ca_high    db    0a3h + 40h
  57. ca_low    db    0a3h
  58.  
  59.  
  60. enable_network:
  61.     mov    ca_high,087h + 40h
  62.     mov    ca_low,087h
  63.     ret
  64.  
  65.  
  66. reset_586:
  67. ;  Reset the chip
  68.     loadport
  69.     setport    IOC
  70.     mov    al,0a3h
  71.     out    dx,al        ; reset the chip
  72.     jmp    $+2
  73.     jmp    $+2
  74.     jmp    $+2
  75.     mov    al,23h
  76.     out    dx,al        ; reset the chip
  77.     jmp    $+2
  78.     jmp    $+2
  79.     jmp    $+2
  80.     mov    al,0a3h
  81.     out    dx,al        ; reset the chip
  82.     jmp    $+2
  83.     jmp    $+2
  84.     jmp    $+2
  85.     ret
  86.  
  87.     public    get_address
  88. get_address:
  89. ;get the address of the interface.
  90. ;enter with es:di -> place to get the address, cx = size of address buffer.
  91. ;exit with nc, cx = actual size of address, or cy if buffer not big enough.
  92.     assume    ds:code
  93.     cmp    cx,EADDR_LEN        ;make sure that we have enough room.
  94.     jb    get_address_2
  95.     mov    cx,EADDR_LEN
  96.     mov    dx,io_addr        ; Get our IO base address.
  97.     cld
  98. get_address_1:
  99.     in    al,dx            ; get a byte of the eprom address
  100.     stosb                ; put it away
  101.     inc    dx            ; next register
  102.     loop    get_address_1        ; go back for rest
  103.     mov    cx,EADDR_LEN
  104.     clc
  105.     ret
  106. get_address_2:
  107.     stc
  108.     ret
  109.  
  110.  
  111. doca:
  112. ;we may be called from places in which ds is unknown.
  113.     assume    ds:nothing
  114.     loadport
  115.     setport IOC
  116.     mov    al,ca_high
  117.     pushf
  118.     cli
  119.     out    dx, al
  120.     jmp    $+2
  121.     jmp    $+2
  122.     jmp    $+2
  123.     mov    al,ca_low
  124.     out    dx, al
  125.     popf
  126.     ret
  127.     assume    ds:code
  128. ;yet, we really should assume ds==code for the rest of this stuff.
  129.  
  130.  
  131. ;
  132. ; Here we include the code that is common between 82586 implementations.
  133. ; Everything above this is resident.
  134.     include    82586.asm
  135. ; Everything below this is discarded upon installation.
  136.  
  137.     public    usage_msg
  138. usage_msg    db    "usage: 3c523 [-n] [-d] [-w] <packet_int_no> <int_no> <io_addr> <base_addr>",CR,LF,'$'
  139.  
  140.     public    copyright_msg
  141. copyright_msg    db    "Packet driver for the 3C523, version ",'0'+(majver / 10),'0'+(majver mod 10),".",'0'+version,".",'0'+i82586_version,CR,LF
  142.         db    "Portions Copyright 1988 The Board of Trustees of the University of Illinois",CR,LF,'$'
  143.  
  144. comment \
  145.  
  146.     The 3c523 responds with adapter code 0x6042 at slot
  147. registers xxx0 and xxx1.  The setup register is at xxx2 and
  148. contains the following bits:
  149.  
  150. 0: card enable
  151. 2,1: csr address select
  152.     00 = 0300
  153.     01 = 1300
  154.     10 = 2300
  155.     11 = 3300
  156. 4,3: shared memory address select
  157.     00 = 0c0000
  158.     01 = 0c8000
  159.     10 = 0d0000
  160.     11 = 0d8000
  161. 5: set to disable on-board thinnet
  162. 7,6: (read-only) shows selected irq
  163.     00 = 12
  164.     01 = 7
  165.     10 = 3
  166.     11 = 9
  167.  
  168. The interrupt-select register is at xxx3 and uses one bit per irq.
  169.  
  170. 0: int 12
  171. 1: int 7
  172. 2: int 3
  173. 3: int 9
  174.  
  175.     Again, the documentation stresses that the setup register
  176. should never be written.  The interrupt-select register may be
  177. written with the value corresponding to bits 7.6 in
  178. the setup register to insure corret setup.
  179.  
  180. \
  181.  
  182. IRQ_MASK    equ    0c0h
  183. IRQ_TABLE    db    12            ; Interrupt Value 0
  184.         db    7            ; Interrupt Value 1
  185.         db    3            ; Interrupt Value 2
  186.         db    9            ; Interrupt Value 3
  187.  
  188. check_board:
  189.     mov    SCP,0            ; 16 bit bus type in scb.
  190.  
  191. ; search all slots for a 3c523 card
  192.     mov    cx, 8            ; for all channels(slots)
  193.  
  194. ; channel select value for slots 0,1,2.. is 8,9,A etc
  195. ; start with slot 0, and then 7,6,5,4,3,2,1
  196. get_05:
  197.     mov    ax, cx            ; channel number
  198.     or    ax, 08h            ; reg. select value
  199.     out    96h, al            ; select channel
  200.  
  201. ; read adapter id
  202.     mov    dx, 101h
  203.     in    al, dx            ; adapter id - ms byte
  204.     mov    ah, al
  205.     dec    dx
  206.     in    al, dx            ; adapter id - ls byte
  207.  
  208. ; Check if 3c523
  209.     cmp    ax, 06042h
  210.     je    get_10
  211.     loop    get_05
  212.  
  213.     mov    dx,offset no_3c523_msg
  214.     jmp    error
  215.  
  216. get_10:
  217. ; found our Adapter
  218.  
  219. ; Get 3c523 IRQ ( read POS Register 0 )
  220.     mov    dx,102h
  221.     in    al,dx
  222.     mov    bl,al
  223.     and    bx,IRQ_MASK
  224.     mov    cl,6
  225.     shr    bx,cl
  226.     mov    al,IRQ_TABLE[bx]
  227.     mov    int_no,al
  228.  
  229. ; Get 3c523 memory address ( read POS Register 0 )
  230.     mov    dx,102h
  231.     in    al,dx
  232.     mov    bl,al
  233.     xor    bh,bh
  234.     mov    cl,11-3
  235.     shl    bx,cl
  236.     and    bx,01800h
  237.     or    bx,0c000h
  238.     mov    base_addr,bx
  239.  
  240. ; Get 3c523 I/O address ( read POS Register 0 )
  241.     mov    dx,102h
  242.     in    al,dx
  243.     mov    bl,al
  244.     xor    bh,bh
  245.     mov    cl,12-1            ;should start at bit 12, now at bit 1.
  246.     shl    bx,cl
  247.     and    bx,3000h
  248.     or    bx,0300h
  249.     mov    io_addr,bx
  250.  
  251.     mov    dx, 102h
  252.     in    al,dx
  253.     or    al,1            ;enable the card.
  254.     out    dx,al
  255.  
  256.     xor    al,al
  257.     out    96h,al            ;deselect the card.
  258.  
  259.     ret
  260.  
  261. no_3c523_msg    db    "No 3c523 found in your system.",CR,LF,'$'
  262.  
  263.     public    parse_args
  264. parse_args:
  265.     mov    di,offset int_no
  266.     call    get_number
  267.     mov    di,offset io_addr
  268.     call    get_number
  269.     mov    di,offset base_addr
  270.     call    get_number
  271.     clc
  272.     ret
  273.  
  274.  
  275. int_no_name    db    "Interrupt number ",'$'
  276. io_addr_name    db    "I/O port ",'$'
  277. base_addr_name    db    "Memory address ",'$'
  278.  
  279.  
  280.     public    print_parameters
  281. print_parameters:
  282.     mov    di,offset int_no
  283.     mov    dx,offset int_no_name
  284.     call    print_number
  285.     mov    di,offset io_addr
  286.     mov    dx,offset io_addr_name
  287.     call    print_number
  288.     mov    ax,memory_begin
  289.     mov    cl,4
  290.     shr    ax,cl
  291.     add    base_addr,ax
  292.     push    ax
  293.     mov    di,offset base_addr
  294.     mov    dx,offset base_addr_name
  295.     call    print_number
  296.     pop    ax
  297.     sub    base_addr,ax
  298.     ret
  299.  
  300.     include    memtest.asm
  301.  
  302. code    ends
  303.  
  304.     end
  305.  
  306.